/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package phpgen;

import java.awt.Component;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.TreeCellRenderer;

/**Renderiza a árvore com icones personalizados de acordo com a altura
*. @author rodson
 *
 */
 class RenderizarTree extends DefaultTreeCellRenderer implements TreeCellRenderer {  
  
       
     public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {  
         super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);  
           
         DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
         
         if(node.getLevel() == 0) {
             java.net.URL imageURL = this.getClass().getClassLoader().getResource("phpgen/resources/bd.png");
             setIcon(new javax.swing.ImageIcon(imageURL));
         }

         if(node.getLevel() == 1) {
             java.net.URL imageURL = this.getClass().getClassLoader().getResource("phpgen/resources/schema.png");
             setIcon(new javax.swing.ImageIcon(imageURL));
         }

         if(node.getLevel() == 2) {
             java.net.URL imageURL = this.getClass().getClassLoader().getResource("phpgen/resources/tabela.png");
             setIcon(new javax.swing.ImageIcon(imageURL));
         }

         if(node.getLevel() == 3) {
             java.net.URL imageURL = this.getClass().getClassLoader().getResource("phpgen/resources/coluna.png");
             setIcon(new javax.swing.ImageIcon(imageURL));
         }


           
         return this;  
     }  
 }



